/*
 * @Description: 转到其他类型库
 * @Author: Rfan
 * @Date: 2022-06-22 09:51:33
 * @LastEditTime: 2022-08-09 19:51:47
 */
import { useMemo, useState } from 'react';
import ReplaceRecordDialog from '../../ReplaceRecord';
import { useArrangementContext } from '@/view/scatteredRecord/Arrangement/contexts/ArrangementContext';

interface ITransferOtherProps {
  info: any;
  selectItems: number[];
}

const TransferInArchive = (props: ITransferOtherProps) => {
  const { selectItems } = props;
  const { transferInFunc } = useArrangementContext();

  // 选择归档位置弹窗
  const [visible, setVisible] = useState(false);

  const selectPlaceClose = (data?: any) => {
    if (data) {
      console.log('selectPlaceClose', data);
      transferInFunc(data).then((res: any) => {
        setVisible(false);
      });
    } else {
      setVisible(false);
    }
  };

  return (
    <>
      <div
        onClick={() => {
          setVisible(true);
        }}
      >
        移入档案库
      </div>
      {useMemo(
        () => (
          <ReplaceRecordDialog
            visible={visible}
            type="transfer"
            selectItems={selectItems}
            onClose={selectPlaceClose}
          />
        ),
        [visible]
      )}
    </>
  );
};

export default TransferInArchive;
